"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SpinMiniLayout = void 0;

var _components = require("@tarojs/components");

var _react = _interopRequireDefault(require("react"));

var _configContext = require("../../../extends/configContext");

var _classnames = _interopRequireDefault(require("classnames"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var SpinMiniLayout = function SpinMiniLayout(_ref) {
  var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'circular' : _ref$type,
      vertical = _ref.vertical,
      size = _ref.size,
      color = _ref.color,
      className = _ref.className,
      _ref$style = _ref.style,
      style = _ref$style === void 0 ? {} : _ref$style,
      children = _ref.children;

  var _useConfig = (0, _configContext.useConfig)(),
      clsPrefix = _useConfig.clsPrefix;

  return /*#__PURE__*/_react.default.createElement(_components.View, {
    className: (0, _classnames.default)("".concat(clsPrefix, "-spin"), className, _defineProperty({}, "".concat(clsPrefix, "-spin--vertical"), vertical)),
    style: _objectSpread({
      color: color
    }, style)
  }, /*#__PURE__*/_react.default.createElement(_components.View, {
    className: "".concat(clsPrefix, "-spin__icon"),
    style: size ? {
      width: size,
      height: size
    } : {}
  }, type === 'circular' ? /*#__PURE__*/_react.default.createElement(_components.View, {
    className: "".concat(clsPrefix, "-spin--circular")
  }) : /*#__PURE__*/_react.default.createElement(_components.View, {
    className: "".concat(clsPrefix, "-spin--spinner")
  }, new Array(12).fill(null).map(function (_, index) {
    return /*#__PURE__*/_react.default.createElement(_components.View, {
      key: index,
      className: "".concat(clsPrefix, "-spin__blade")
    });
  }))), /*#__PURE__*/_react.default.createElement(_components.View, {
    className: "".concat(clsPrefix, "-spin__text")
  }, children));
};

exports.SpinMiniLayout = SpinMiniLayout;